$(function(){
  /*禁用确认重新提交表单*/
  window.history.replaceState(null,null,window.location.href)
})


/*判断是否登录*/
$(function(){
	if($("#logig_nameShow").text() == ""){
		$("#logig_nameShow").text("登录");
	}
})


/* 爱心模式 */
var num = 0;
$("#heart_schema").click(function() {
  if( num == 0){
     $("#heart").show(1).slideDown(1).fadeIn();
     /*获取滚动条高度*/
     $(window).scroll(function(){
        if($(window).scrollTop()>=100){
          $("#heart").css("z-index","1000");
          $("#heart").css({"position":"fixed","top":"0px"});
        }else{
          $("#heart").css("position","relative");
        }
     })
     num=1;
  }else if(num==1){
    $("#heart").hide(500).slideUp(500).fadeOut();
    num = 0;
  }
})

/*退出爱心模式*/
$("#heart_exit").click(function() {
  $("#heart").hide(500).slideUp(500).fadeOut();
})

/* 修改heart_point 下img标签中src图片路径 */
$("#heart_point").click(function() {
  $("#heart_point").find("img").css("content","url(images/continuous_stop1.png)");
})

/*固定导航栏*/
$("#fixed_2").mouseenter(function(){
  $("#fixeds").show(100);
});

$("#fixed_2").mouseleave(function(){
  $("#fixeds").hide(100);
});

 // 搜索按钮
$("#search—bon").mouseover(function(){
	$("#search—bon").css("backgroundColor","blue");
})
$("#search—bon").mouseout(function(){
	$("#search—bon").css("backgroundColor","#3B99FC");
})

/* 实现English下拉单  显示*/
$("#Englishs").mouseenter(function(){
	$("#EnglishSlide").show(1).slideDown(1).fadeIn();

})

$("#Englishs").mouseleave(function(){
	$("#EnglishSlide").hide(1).slideUp(1).fadeOut();
})


/* 实现我的12306下拉单  显示*/
$("#myslide").mouseenter(function(){
	$("#my12306").show(1).slideDown(1).fadeIn();
})

$("#myslide").mouseleave(function(){
	$("#my12306").hide(1).slideUp(1).fadeOut();
})


/* 实现导航条中的效果*/
$(".n_arrow").parents("li").mouseover(function(){
	$(this).find($(".n_arrow")).css("animation","boxIn 0.5s  ease-in forwards");
	$(this).css("backgroundColor","#2676E3");
})

$(".n_arrow").parents("li").mouseout(function(){
	$(this).find($(".n_arrow")).css("animation","boxout 0.5s  ease-in forwards");
	$(this).css("backgroundColor","#3B99FC")
})

/* 实现导航条中的下拉列表*/
/*导航条>车票*/
$("#n_arrow_ticket").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#ticket").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_ticket").mouseleave(function(){
  $("#ticket").hide(10).slideUp(10).fadeOut();
})

/*导航条>团购服务*/
$("#n_arrow_team").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#team").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_team").mouseleave(function(){
  $("#team").hide(10).slideUp(10).fadeOut();
})

/*导航条>会员服务*/
$("#n_arrow_vipServe").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#vipServe").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_vipServe").mouseleave(function(){
  $("#vipServe").hide(10).slideUp(10).fadeOut();
})

/*导航条>站车服务*/
$("#n_arrow_station").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#station").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_station").mouseleave(function(){
  $("#station").hide(10).slideUp(10).fadeOut();
})

/*导航条>商旅服务*/
$("#n_arrow_tour").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#tour").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_tour").mouseleave(function(){
  $("#tour").hide(10).slideUp(10).fadeOut();
})

/*导航条>出行指南*/
$("#n_arrow_trip").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#trip").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_trip").mouseleave(function(){
  $("#trip").hide(10).slideUp(10).fadeOut();
})

/*导航条>信用信息*/
$("#n_arrow_message").mouseenter(function(){
  $(".navigation").hide(10).slideUp(10).fadeOut();
  $("#message").show(10).slideDown(10).fadeIn();
})

$("#n_arrow_message").mouseleave(function(){
  $("#message").hide(10).slideUp(10).fadeOut();
})


/*广告轮播图*/
//定义全局变量和定时器
var i = 0 ;
var timer;
$(document).ready(function(){
  //用jquery方法设置第一张图片显示，其余隐藏
  $('.ig').eq(0).show().siblings('.ig').hide();
  //调用showTime()函数（轮播函数）
  showTime();
  //当鼠标经过下面的数字时，触发两个事件（鼠标悬停和鼠标离开）
  $('.con-tab').hover(function(){
    //获取当前i的值，并显示，同时还要清除定时器
    i = $(this).index();
    Show();
    clearInterval(timer);
  },function(){
    showTime();
  });
});

//创建一个showTime函数
function showTime(){
  //定时器
  timer = setInterval(function(){
    //调用一个Show()函数
    Show();
    i++;
    //当图片是最后一张的后面时，设置图片为第一张
    if(i==6){
      i=0;
    }
  },2000);
}
//创建一个Show函数
function Show(){
  //在这里可以用其他jquery的动画
  $('.ig').eq(i).fadeIn(300).siblings('.ig').fadeOut(300);
  //给.con-tab创建一个新的Class为其添加一个新的样式，并且要在css代码中设置该样式
  $('.con-tab').eq(i).addClass('bg').siblings('.con-tab').removeClass('bg');
}


/*获取日期并转换成相应格式*/
var now = new Date();
var year = now.getFullYear();
/*month返回数组（0-11）*/
var month = ("0" + (now.getMonth() + 1)).slice(-2);
/*getDate返回日期(1-31)*/
var day = ("0" + now.getDate()).slice(-2);
var formatedDate = year + "-" + month + "-" + day;
/*设置车票》单程》出发日期*/
$(".now_date").val(formatedDate);

/*车票*/
$("#search-side-ticket").click(function(){
  $("#search-side").find("dl").css("backgroundColor","#3B99FC");
  $("#search-side").find("dd").css("color","white");
  $("#search-side-ticket").css("backgroundColor","white");
  $("#search-side-ticket").find("dd").css("color","#3B99FC");
  $(".search_main_item").css("display","none");
  $("#main_ticket").show(1);
  $("#book_meal_main").hide(1);
  $("#refer_main").hide(1);
  $("#ticket_main").show(1);
  $("#ticket_one_way").show(1);
  $("#search-tab-hd-one").css("borderBottom","2px solid #3B99FC");
  $("#search-side-com-question").find("dt").css("backgroundImage","url('images/19-6-2022_14590.jpeg')");
  $("#search-side-cook").find("dt").css("backgroundImage","url('images/19-6-2022_15045.jpeg')");
  $(this).find("dt").css("backgroundImage","url('images/19-6-2022_145455_.jpeg')");
})

/*车票>>单程>切换*/
$("#one_way_cut").mouseover(function(){
  $("#cuts_way").show();
})

$("#one_way_cut").mouseout(function(){
  $("#cuts_way").hide();
})

$("#one_way_cut").click(function(){
  var depart = $("#one_way_depart").val();
  var getTo = $("#one_way_get_to").val();
  $("#one_way_depart").val(getTo);
  $("#one_way_get_to").val(depart);
})

/*车票>>往返>切换*/
$("#commute_cut").mouseover(function(){
  $("#cuts_commute").show();
})

$("#commute_cut").mouseout(function(){
  $("#cuts_commute").hide();
})

$("#commute_cut").click(function(){
  var depart = $("#commute_depart").val();
  var getTo = $("#commute_get_to").val();
  $("#commute_depart").val(getTo);
  $("#commute_get_to").val(depart);
})

/*车票>>中转换乘>切换*/
$("#transfer_cut").mouseover(function(){
  $("#cuts_transfer").show();
})

$("#transfer_cut").mouseout(function(){
  $("#cuts_transfer").hide();
})

$("#transfer_cut").click(function(){
  var depart = $("#transfer_depart").val();
  var getTo = $("#transfer_get_to").val();
  $("#transfer_depart").val(getTo);
  $("#transfer_get_to").val(depart);
})

/*车票>>单程*/
$("#navigation_one_way").click(function(){
  if( $("#ticket_one_way").css("display") == "none"){
    $(".search_tab_item").hide(1);
    $("#ticket_one_way").show(1);
    $(".search-tab-hds").css("borderBottom","0px");
    $(".search-tab-hds").css("color"," #999999");
    $(this).css("color","#3B99FC");
    $(this).css("borderBottom","2px solid #3B99FC");
  }
})

/*车票>>往还*/
$("#navigation_commute").click(function(){
  $(".search_tab_item").hide(1);
  $("#ticket_commute").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})

/*车票>>转换乘*/
$("#navigation_transfer").click(function(){
  $(".search_tab_item").hide(1);
  $("#ticket_transfer").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})
/*车票>>退改签*/
$("#navigation_quit_change_sign").click(function(){
  $(".search_tab_item").hide(1);
  $("#ticket_quit_change_sign").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})

/*常用查询*/
$("#search-side-com-question").click(function(){
  $("#search-side").find("dl").css("backgroundColor","#3B99FC");
  $("#search-side").find("dd").css("color","white");
  $("#search-side-com-question").css("backgroundColor","white");
  $("#search-side-com-question").find("dd").css("color","#3B99FC");
  $(".search_main_item").css("display","none");
  $(".search_tab_item").hide(1);
  $("#ticket_main").hide(1);
  $("#book_meal_main").hide(1);
  $("#refer_main").show(1);
  $("#com-even").css("borderBottom","2px solid #3B99FC");
  $("#search-side-ticket").find("dt").css("backgroundImage","url('images/19-6-2022_145629.jpeg')");
  $("#search-side-cook").find("dt").css("backgroundImage","url('images/19-6-2022_15045.jpeg')");
  $(this).find("dt").css("backgroundImage","url('images/19-6-2022_145755.jpeg')");
})

/*常用查询>正晚点*/
$("#navigation_behind_schedule").click(function(){
  if( $("#refer_behind_schedule").css("display") == "none"){
    $(".refer_tab_item").hide(1);
    $("#refer_behind_schedule").show(1);
    $(".search-tab-hds").css("borderBottom","0px");
    $(".search-tab-hds").css("color"," #999999");
    $(this).css("color","#3B99FC");
    $(this).css("borderBottom","2px solid #3B99FC");
  }
 
})

/*常用查询>检票口*/
$("#navigation_inspect_ticket").click(function(){
  $(".refer_tab_item").hide(1);
  $("#refer_inspect_ticket").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})

/*常用查询>起售时间*/
$("#navigation_for_sale_time").click(function(){
  $(".refer_tab_item").hide(1);
  $("#refer_for_sale_time").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})

/*常用查询>天气查询*/
$("#navigation_weather").click(function(){
  $(".refer_tab_item").hide(1);
  $("#refer_weather").show(1);
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})

/*订餐*/
$("#search-side-cook").click(function(){
  $("#search-side").find("dl").css("backgroundColor","#3B99FC");
  $("#search-side").find("dd").css("color","white");
  $("#search-side-cook").css("backgroundColor","white");
  $("#search-side-cook").find("dd").css("color","#3B99FC");
  $(".search_main_item").css("display","none");
  $(".search_tab_item").hide(1);
  $("#ticket_main").hide(1);
  $("#refer_main").hide(1);
  $("#book_meal_main").show(1);
  $("#meal_order").css("borderBottom","2px solid #3B99FC");
  $("#search-side-com-question").find("dt").css("backgroundImage","url('images/19-6-2022_14590.jpeg')");
  $("#search-side-ticket").find("dt").css("backgroundImage","url('images/19-6-2022_145629.jpeg')");
  $(this).find("dt").css("backgroundImage","url('images/19-6-2022_145957.jpeg')");
})

/*订餐>预订*/
$("#navigation_book_meal_book").click(function(){
  if( $("#book_meal_book").css("display") == "none"){
    $(".book_tab_item").hide(1);
    $("#book_meal_book").show(1);
    $(".search-tab-hds").css("borderBottom","0px");
    $(".search-tab-hds").css("color"," #999999");
    $(this).css("color","#3B99FC");
    $(this).css("borderBottom","2px solid #3B99FC");
  }
})

/*订餐>餐饮订单*/
$("#navigation_meal_ident").click(function(){
  $(location).attr("href","https://exservice.12306.cn/excater/queryMyOrder.html");
  $(".search-tab-hds").css("borderBottom","0px");
  $(".search-tab-hds").css("color"," #999999");
  $(this).css("color","#3B99FC");
  $(this).css("borderBottom","2px solid #3B99FC");
})


/*常用查询*/
$("#search-side-com-question").click(function(){
  $("#search-side").find("li").css("backgroundColor","#3B99FC");
  $("#search-side").find("a").css("color","white");
  $("#search-side-com-question").css("backgroundColor","white");
  $("#search-side-com-question").find("a").css("color","#3B99FC");
  $(".search_main_item").css("display","none");
  $("#main-com-refer").show(1000).fadeIn(1000);
})

/*订餐*/
$("#search-side-cook").click(function(){
  $("#search-side").find("li").css("backgroundColor","#3B99FC");
  $("#search-side").find("a").css("color","white");
  $("#search-side-cook").css("backgroundColor","white");
  $("#search-side-cook").find("a").css("color","#3B99FC");
  $(".search_main_item").css("display","none");
  $("#main-order-meal").show(1000).fadeIn(1000);
})


/*最新发布*/
$("#news-li").click(function(){
  $(".down-head-li").css("backgroundColor","white");
  $(".down-head-li").css("color","#666666");
  $("#news-li").css("backgroundColor","#3B99FC");
  $("#news-li").css("color","white");
  $(".com_issue").hide(0);
  $(".betray_pub").hide(0);
  $(".news").show(1000).fadeIn(1000);
})
/*常见问题*/
$("#com-issue-li").click(function(){
  $(".down-head-li").css("backgroundColor","white");
  $(".down-head-li").css("color","#666666");
  $("#com-issue-li").css("backgroundColor","#3B99FC");
  $("#com-issue-li").css("color","white");
  $(".news").hide(0);
  $(".betray_pub").hide(0);
  $(".com_issue").show(1000).fadeIn(1000);
})
/*信用信息*/
$("#betray-pub-li").click(function(){
  $(".down-head-li").css("backgroundColor","white");
  $(".down-head-li").css("color","#666666");
  $("#betray-pub-li").css("backgroundColor","#3B99FC");
  $("#betray-pub-li").css("color","white");
  $(".news").hide(0);
  $(".com_issue").hide(0);
  $(".betray_pub").show(1000).fadeIn(1000);
})